﻿using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TYPLC;

namespace TYComm_For_DSApp.View
{
    public class ViewModel_Data_Control : ViewModelBase
    {
        public ViewModel_Data_Control()
        {
            ListGroup.Add(new PLCGroupModel
            {
                GroupName = "test1",
                ListTags = new ObservableCollection<PLCTagModel>
                { new PLCTagModel() { Address = "123" } }
            });
            ListGroup.Add(new PLCGroupModel
            {
                GroupName = "test2",
                ListTags = new ObservableCollection<PLCTagModel>
                { new PLCTagModel() { Address = "123" } }
            });
            ListGroup.Add(new PLCGroupModel
            {
                GroupName = "test3",
                ListTags = new ObservableCollection<PLCTagModel>
                { new PLCTagModel() { Address = "123" } }
            });
        }

        private ObservableCollection<PLCGroupModel> _ListGroup = new ObservableCollection<PLCGroupModel>();
        public ObservableCollection<PLCGroupModel> ListGroup { get { return _ListGroup; } set { Set("ListGroup", ref _ListGroup, value); } }

        private PLCGroupModel _SelectedGroup;
        public PLCGroupModel SelectedGroup { get => _SelectedGroup; set => Set("SelectedGroup", ref _SelectedGroup, value); }
    }

    public class PLCTagModel : ViewModelBase
    {
        private int _Index;
        public int Index { get => _Index; set => Set("Index", ref _Index, value); }

        private string _TagName;
        public string TagName { get => _TagName; set => Set("TagName", ref _TagName, value); }

        private int _TagIndex;
        public int TagIndex { get => _TagIndex; set => Set("TagIndex", ref _TagIndex, value); }

        private string _Address;
        public string Address { get => _Address; set => Set("Address", ref _Address, value); }

        private PLCDataType _DataType;
        public PLCDataType DataType { get => _DataType; set => Set("DataType", ref _DataType, value); }

        private int _DataLength;
        public int DataLength { get => _DataLength; set => Set("DataLength", ref _DataLength, value); }
    }

    public class PLCGroupModel : ViewModelBase
    {
        private string _GroupName;
        public string GroupName { get => _GroupName; set => Set("GroupName", ref _GroupName, value); }

        private ObservableCollection<PLCTagModel> _ListTags = new ObservableCollection<PLCTagModel>();
        public ObservableCollection<PLCTagModel> ListTags { get { return _ListTags; } set { Set("ListTags", ref _ListTags, value); } }
    }
}